<?php

if (!isset($_GET['id'])) $id = 0;
else $id = $_GET['id'];

if ($id>0) {
	$query = "SELECT * FROM stanica WHERE id=" . $id . ";";
	$result = myQuery($query);
	if (! ($row = mysql_fetch_array($result))) myDie("Kriticna greska sa id od stanica... ", "kemikalije.php");
	$action = "edit&type=stanica&id=" . $row['id'];
}
else $action = "new&type=stanica";

print("<form method='POST' action=\"exec/stanice.php?action=" . $action . "\">");
?>

<table>
<tr>
<td width='50%'>
	<div class='content'>
	<span class='contentTitle'> Informacije o stanici </span>
	<table class='tableResult' cellspacing='0' width='100%'>
	<tr> 
		<th scope='row' class='spec' width='110px' > Naziv </th> 
		<td> 
			<input type='text' name='stanicaNaziv' id='stanicaNaziv' size='45'
				<?php if ($id>0) print("value='" . $row['naziv'] . "'");?> > 
		</td>
	</tr>
	
	<tr>
		<th scope='row' class='spec' > Podrijetlo </th> 
		<td>
			<select name='stanicaPodrijetlo' id='stanicaPodrijetlo' style="width: 310px">
			<?php printOptionsOfAtributes("podrijetlo", "naziv") ?>
			</select>
		</td>
	</tr>
	
	<tr>
		<th scope='row' class='spec' > Izotip </th> 
		<td>
			<select name='stanicaIzotip' id='stanicaIzotip' style="width: 310px">
			<?php printOptionsOfAtributes("izotip", "naziv") ?>
			</select>
		</td>
	</tr>
	
	<tr>
		<th scope='row' class='spec' > Medij </th> 
		<td>
			<select name='stanicaMedij' id='stanicaMedij' style="width: 310px">
			<?php printOptionsOfAtributes("medij", "naziv") ?>
			</select>
		</td>
	</tr>

	<tr> 
		<th scope='row' class='spec' > Dodatak<br>u medij </th> 
		<td>
			<textarea rows="3" cols="36" name="stanicaDodatak"><?php if ($id>0) print($row['dodatak']);?></textarea>
		</td> 
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Karakteristike </th> 
		<td>
			<textarea rows="3" cols="36" name="stanicaKarakteristike"><?php if ($id>0) print($row['karakteristike']);?></textarea>
		</td> 
	</tr>
		
	<tr> 
		<th scope='row' class='spec' > Referenca </th> 
		<td>
			<textarea rows="3" cols="36" name="stanicaReferenca"><?php if ($id>0) print($row['referenca']);?></textarea>
		</td> 
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Pasaža </th> 
		<td>
			<textarea rows="3" cols="36" name="stanicaPasaza"><?php if ($id>0) print($row['pasaza']);?></textarea>
		</td> 
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Opaske </th> 
		<td>
			<textarea rows="3" cols="36" name="stanicaOpaske"><?php if ($id>0) print($row['opaska']);?></textarea>
		</td> 
	</tr>
				
	<tr> 
		<th scope='row' class='spec' > Vlasnik </th> 
		<td> 
			<input type='text' name='stanicaVlasnik' id='stanicaVlasnik' size='45'
				<?php if ($id>0) print("value='" . $row['vlasnik'] . "'");?> >
		</td> 
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Link </th> 
		<td> 
			<input type='text' name='stanicaLink' id='stanicaLink' size='45'
				<?php if ($id>0) print("value='" . $row['link'] . "'");?> >
		</td> 
	</tr>
	
	</table>
	</div>
</td>

<td valign="top">
	<div class='content'>
	<span class='contentTitle'> Lokacija u tekućem dušiku  </span>
	<table class='tableResult' cellspacing='0' width='100%'>
	<tr> 
		<th scope='row' class='spec' > Spremnik </th> 
		<td>
			<select name='stanicaSpremnik' id='stanicaSpremnik' style="width: 310px">
				<?php printOptionsOfAtributes("spremnik", "naziv") ?>
			</select>
		</td>
	</tr>
		
	<tr> 
		<th scope='row' class='spec' > Polica - Rack </th> 
		<td>
			<select name='stanicaPolica' id='stanicaPolica' style="width: 100px">
				<?php for ($i=1; $i<=4; $i++) print("<option value='" . $i . "'>" . $i . "</option>"); ?>
			</select> - 
			<select name='stanicaRack' id='stanicaRack' style="width: 100px">
				<?php for ($i=1; $i<=4; $i++) print("<option value='" . $i . "'>" . $i . "</option>"); ?>
			</select>
		</td>
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Kolona - Ladica </th> 
		<td> 
			<select name='stanicaKolona' id='stanicaKolona' style="width: 100px">
				<?php for ($i='A'; $i<='F'; $i++) print("<option value='" . $i . "'>" . $i . "</option>"); ?>
			</select> - 
			<select name='stanicaLadica' id='stanicaLadica' style="width: 100px">
				<?php for ($i=1; $i<=9; $i++) print("<option value='" . $i . "'>" . $i . "</option>"); ?>
			</select>
		</td>
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Red - Položaj </th> 
		<td> 
			<select name='stanicaRed' id='stanicaRed' style="width: 100px">
				<?php for ($i=1; $i<=9; $i++) print("<option value='" . $i . "'>" . $i . "</option>"); ?>
			</select> -
			<select name='stanicaPolozaj' id='stanicaPolozaj' style="width: 100px">
				<?php for ($i=1; $i<=9; $i++) print("<option value='" . $i . "'>" . $i . "</option>"); ?>
			</select>
		</td>
	</tr>
	
	<tr> 
		<th scope='row' class='spec' > Datum spremanja </th> 
		<td> 
			<input type='text' name='stanicaDatum' id='stanicaDatum' size='27'
				<?php if ($id>0) print("value='" . $row['datum'] . "'");?> > (yyyy-mm-dd)
		</td>
	</tr>

	
	<tr> 
		<th scope='row' class='spec' > Osoba koja je spremila stanicu </th> 
		<td> 
			<input type='text' name='stanicaOsoba' id='stanicaOsoba' size='45'
				<?php if ($id>0) print("value='" . $row['osoba'] . "'");?> />
		</td> 
	</tr>
	<tr>
		<th scope='row' class='spec' colspan='2'><center><input type='submit' value='Spremi promjene'></center>  </th>
	</tr>
	</table>
	</div>
</td>

</tr>
</table>

<?php print("</form>"); ?>